package com.nlscan.ncomgateway.core.profile

import com.nlscan.ble.util.NLogUtil
import com.nlscan.ncomgateway.core.data.preference.SettingsPreferenceManager
import com.nlscan.ncomgateway.core.newland.entity.BroadcastOutputParams
import com.nlscan.ncomgateway.core.newland.profile.IProfileStrategy

/**
 * 设置Scanner 应用本身sp Profile值
 * 本地值
 */
object AppProfileStrategy : IProfileStrategy {

    override fun updateSettings(): HashMap<String, String?>? {
        //do nothing
        NLogUtil.e("AppProfileStrategy No support api: updateSettingsMap")
        return null
    }

    override fun getOutputMode(): Int {
        return SettingsPreferenceManager.getOutputMode()
    }

    override fun setOutputMode(mode: Int) {
        return SettingsPreferenceManager.setOutputMode(mode)
    }

    override fun getBroadcastOutputAction(): String {
        return SettingsPreferenceManager.getBroadcastOutputAction()
    }

    fun setBroadcastOutputAction(value: String) {
        return SettingsPreferenceManager.setBroadcastOutputAction(value)
    }

    override fun getBroadcastOutputExtraResult(): String {
        return SettingsPreferenceManager.getBroadcastOutputExtraResult()
    }

    fun setBroadcastOutputExtraResult(value: String) {
        return SettingsPreferenceManager.setBroadcastOutputExtraResult(value)
    }

    override fun getBroadcastOutputParams(): BroadcastOutputParams {
        return BroadcastOutputParams(
            exScannerAction = getBroadcastOutputAction(),
            exScannerExtraBarcode = getBroadcastOutputExtraResult(),
            exScannerExtraDeviceName = SettingsPreferenceManager.getBroadcastOutputExtraDeviceName(),
            exScannerExtraAddress = SettingsPreferenceManager.getBroadcastOutputExtraAddress(),
            exScannerExtraSerialNumber = SettingsPreferenceManager.getBroadcastOutputExtraSerialNumber(),
            exScannerExtraBarcodeType = SettingsPreferenceManager.getBroadcastOutputExtraBarcodeType(),
            exScannerExtraBarcodeTypeName = SettingsPreferenceManager.getBroadcastOutputExtraBarcodeTypeName()
        )
    }

    override fun setBroadcastOutputParams(params: BroadcastOutputParams) {
        setBroadcastOutputAction(params.exScannerAction)
        setBroadcastOutputExtraResult(params.exScannerExtraBarcode)
        SettingsPreferenceManager.setBroadcastOutputExtraDeviceName(params.exScannerExtraDeviceName)
        SettingsPreferenceManager.setBroadcastOutputExtraAddress(params.exScannerExtraAddress)
        SettingsPreferenceManager.setBroadcastOutputExtraSerialNumber(params.exScannerExtraSerialNumber)
        SettingsPreferenceManager.setBroadcastOutputExtraBarcodeType(params.exScannerExtraBarcodeType)
        SettingsPreferenceManager.setBroadcastOutputExtraBarcodeTypeName(params.exScannerExtraBarcodeTypeName)
    }

    override fun setIndicateSoundEnable(enable: Boolean): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: setIndicateSoundEnable")
        return false
    }

    override fun getIndicateVibrateEnable(): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: getIndicateVibrateEnable")
        return false
    }

    override fun setIndicateVibrateEnable(enable: Boolean): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: setIndicateVibrateEnable")
        return false
    }

    override fun getIndicateLedEnable(): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: getIndicateLedEnable")
        return false
    }

    override fun setIndicateLedEnable(enable: Boolean): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: setIndicateLedEnable")
        return false
    }

    override fun getPrefix(): String {
        NLogUtil.e("AppProfileStrategy No support api: getPrefix")
        return ""
    }

    override fun getPrefixEnable(): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: getPrefixEnable")
        return false
    }

    override fun setPrefixParams(value: String, enable: Boolean): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: setPrefixParams")
        return false
    }

    override fun getSuffix(): String {
        NLogUtil.e("AppProfileStrategy No support api: getSuffix")
        return ""
    }

    override fun getSuffixEnable(): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: getSuffixEnable")
        return false
    }

    override fun setSuffixParams(value: String, enable: Boolean): Boolean {
        NLogUtil.e("AppProfileStrategy No support api: setSuffixParams")
        return false
    }

}